package com.kx.center.util;

import java.util.Map;
import java.util.Set;

public class SQLUtil {
	
	public static String builWhere(Map<String,Object> whereMap){
		String where = "1=1";
		
		if(whereMap == null){
			return where;
		}
		
		Set<Map.Entry<String,Object>> entrys = whereMap.entrySet();

		for (Map.Entry<String, Object> entry : entrys) {
			String key = entry.getKey();
			Object val = entry.getValue();
			if(val instanceof Integer){
				where += (" and "+key + "=" + val);
			}else if(val instanceof Double){
				where += (" and "+key + "=" + val);	
			}else if(val instanceof String){
				where += (" and "+key + "='" + val+"'");
			}else{
				where += (" and "+key + "='" + val+"'");
			}
		}
		return where;
	}
	
}
